import com.yanjingzheng.entity.Circle;
import com.yanjingzheng.entity.Shape;

import java.util.HashMap;

/**
 * @Author Yenchingcheng
 * @Date 2023/9/12 16:47
 * @Description 形状工厂类
 **/
public class ShapeFactory {

    private static final HashMap<String, Shape> circleMap = new HashMap<>();

    public static Shape getCircle(String color) {
        Circle circle = (Circle) circleMap.get(color);

        if (circle == null) {
            circle = new Circle(color);
            circleMap.put(color, circle);
            System.out.println("create circle of color:" + color);
        }
        return circle;
    }
}
